﻿<?php
@session_start();
if(isset($_POST))
{
//creation des repertoir pour le stockage des images
	// Declaration de la fonction
		function IsDir_or_CreateIt($path) {
		    if(is_dir($path)) {
		        return true;
		    } else {
		        if(mkdir($path)) {
		            return true;
		        } else {
		            return false;
		        };
		    };
		}

		//creer le repertoir
		$day  = date('d');
		$month  = date('m');
		$year  = date('Y');
		$path = '../article_pic';

		// Utilisation

	
		$mon_dossier = $path.'/'.$year.'/'.$month.'/'.$day.'';

		if(IsDir_or_CreateIt($mon_dossier)) {
		    echo "Le dossier ".$mon_dossier." existe";
		} else {
		    //creer le repertoir
			$day  = date('d');
			$month  = date('m');
			$year  = date('Y');
			$path = '../article_pic';
			mkdir($path.'/'.$year.'/'.$month.'/'.$day, 0777, true);
		};

	
    

	

		require_once("../class/mysql.class.php");
	
		$obj = new Mysql();
		
		$requete = "SELECT * FROM user_login WHERE email_login ='".$_POST["email"]."'";
		$querys = mysql_query($requete);
		$values = mysql_fetch_array($querys);	
	
		echo  $values["email_login"].'<br>';
		echo $_POST["email"];
		
		if($values['email_login']!==$_POST["email"])
			{		
				 header("Location:../index.php?action=incorrect_email");	
			}			
		
		if(($values["email_login"] == $_POST["email"])&&($values["password_login"]!== $_POST["password"]))
			{
				header("Location:../index.php?action=incorrect_password");
			}
								
		if(($values["email_login"] !== $_POST["email"])&&($values["password_login"]!== $_POST["password"]))
			{
				header("Location:../index.php?action=incorrect_login");
			}	
			
		if(($values["email_login"] == $_POST["email"])&&($values["password_login"]== $_POST["password"]))
			{
				$_SESSION["id"] = $values["id_login"];
				$_SESSION["email"] = $values["email_login"];
				
				/****log****/
				
				@$date_activation = date("d-m-Y");
				@$time_activation = date("H:i");
				$req_log = "INSERT INTO `user_log`(`id_log`, `email_login`, `date`, `time`) VALUES 
				('','".$_POST["email"]."','".$date_activation."','".$time_activation."')";
				$resul = mysql_query($req_log);
				header("Location:../list_article.php");
			}
						
}


if((isset($_GET["session"])) && ($_GET["session"] == "invite"))
{
	echo "invi";
	$_SESSION["id"] = 'invite';
	echo $_SESSION["id"];
}
?>